/* 
*
* Watch helper
*
* This script is distributed under the GNU Lesser General Public License.
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
*/


function timerReset(id) {

	this.elem = document.getElementById(id);	
	this.time = 20;
	
	this.timerSet(this.time);
		
 	this.inter=setInterval(function(){timerFunction()},1000);

}

function timerStop(id) {

	this.elem = document.getElementById(id);	
		
 	clearInterval(this.inter);
	
	return (this.time > 0)?1:0;
	
}

function timerSet(time) {
	this.time = time;
	var t = "00" + time;
	this.elem.innerHTML = "00:00:" + t.slice(-2);
}

function timerSet2(id, time) {

	this.elem = document.getElementById(id);	
	this.timerSet(time);
}

function timerFunction() {
	if(this.time > 0)
	{
		this.timerSet(this.time-1);	
	}
	else if ( this.time == 0 )
	{
		this.time -= 1;
		this.elem.innerHTML ="El tiempo expir&oacute <br> Si responde acertadamente obtendr&aacute 2 puntos";
	}
	else
	{
		//avoid extra calls
		clearInterval(this.inter);
	}
	
}

	